<template>
  <div>
    <div class="top">
      <van-icon @click="goback" class="zuo" name="arrow-left" />
      全部订单
    </div>
    <van-tabs v-model="active">
      <van-tab title="全部">
        <van-swipe-cell v-for="i in orderlist" :key="i.orderid">
          <van-card
            num="2"
            :price="i.originprice"
            :desc="i.proname"
            title="生活用品"
            class="goods-card"
            :thumb="i.img1"
          />
          <template #right>
            <van-button
              square
              text="删除"
              type="danger"
              class="delete-button"
              @click="remove"
            />
          </template>
        </van-swipe-cell>
      </van-tab>
      <van-tab title="待付款">
        <van-swipe-cell v-for="i in list" :key="i.orderid">
          <van-card
            num="2"
            :price="i.originprice"
            :desc="i.proname"
            title="生活用品"
            class="goods-card"
            :thumb="i.img1"
          />
          <template #right>
            <van-button
              square
              text="删除"
              type="danger"
              class="delete-button"
              @click="remove"
            />
          </template>
        </van-swipe-cell>
      </van-tab>
      <van-tab title="待收货">待收货</van-tab>
      <van-tab title="已完成">已完成</van-tab>
    </van-tabs>
  </div>
</template>

<script>
import { getconfirm,getorderlist } from "@/api/login";
export default {
  data() {
    return {
      active: 0,
      list: [],
      orderlist: [],
    };
  },
  methods: {
    goback() {
      this.$router.back();
    },
    remove() {
      console.log("删除");
    },
  },
  created() {
    getconfirm({
      userid: localStorage.getItem("userid"),
      time: localStorage.getItem("time"),
    }).then((res) => {
      console.log(res);
      this.list = res.data.data;
    });
    getorderlist({
      userid: localStorage.getItem("userid"),
      time: localStorage.getItem("time"),
    }).then((res) => {
      console.log(res);
      this.orderlist = res.data.data;
    });
  },
};
</script>

<style scoped>
.top {
  width: 100%;
  height: 3.125rem;
  font-size: 1.25rem;
  text-align: center;
  line-height: 3.125rem;
  border-bottom: 0.0625rem solid black;
  position: relative;
  margin-bottom: 1.25rem;
  background-color: red;
}
.zuo {
  position: absolute;
  left: 0.625rem;
  font-size: 1.25rem;
  top: 0.9375rem;
}
.goods-card {
  margin-top: 1.25rem;
  padding: 0.625rem;
  background-color: white;
  background-color: #f4f4f4;
  border-radius: 0.9375rem;
}

.delete-button {
  height: 100%;
}
</style>